#include <iostream>
#include <string>
#include <map>
#include <unordered_map>
using namespace std;

unordered_map<string,int> mp;

int main()
{
	
	int ret = 0;
	int n; cin >> n;
	for(int i = 1;i <= n;i++)
	{
		string s1,s2;cin >> s1 >>s2;
		s1 = s1.substr(0,2);
		if(s1 == s2) continue;
		
		ret += mp[s1 + s2];
		mp[s2 + s1]++;
	}	
	
	cout << ret << endl;
	return 0;
}
